@extends('admin.main')
@section('content')
    <div class="daohang">
        <ul>
            <li>
                <button type="button" class="am-btn am-btn-default am-radius am-btn-xs">医师管理>
                </button>
            </li>
            <li>
                <button type="button" class="am-btn am-btn-default am-radius am-btn-xs">医师列表
                </button>
            </li>
        </ul>
    </div>
    <div class="admin-biaogelist">

        <div class="listbiaoti am-cf">
            <ul class="am-icon-flag on"> 医师管理</ul>

            {{--<dl class="am-icon-home" style="float: right;"> 当前位置：首页 ><a href="#">医师列表</a></dl>--}}

            <dl>
                <a href="{{urlAdmin('doctor','getAdd')}}" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus">添加医师</a>
            </dl>


        </div>

        <div class="am-btn-toolbars am-btn-toolbar am-kg am-cf">
            <form method="get">
                <ul>
                    <li>
                        <div class="am-btn-group am-btn-group-xs">
                            <select name="did" data-am-selected="{btnWidth: 90, btnSize: 'sm', btnStyle: 'default'}">
                                <option value="0" @if(!$did) selected @endif>全部</option>
                                @if($departs)
                                    @foreach($departs as $v)
                                        <option @if($v['id'] == $did) selected
                                                @endif value="{{$v['id']}}">{{$v['name']}}</option>
                                    @endforeach
                                @endif
                            </select>
                        </div>
                    </li>
                    <li><input type="text" class="am-form-field am-input-sm am-input-xm" name="keyword"
                               placeholder="输入医生ID或姓名" value="{{$keyword}}"/></li>
                    <li>
                        <button type="submit" class="am-btn am-radius am-btn-xs am-btn-success"
                                style="margin-top: -1px;">搜索
                        </button>
                    </li>
                </ul>
            </form>
        </div>
        <form class="am-form am-g">
            <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
                <thead>
                <tr class="am-success" align="center">

                    <th width="4%">ID</th>
                    <th width="10%">专家头像</th>
                    <th width="10%">专家名称</th>
                    <th width="10%">职务</th>
                    <th width="10%">职称</th>
                    <th width="15%">所在单位</th>
                    <th width="10%">状态</th>
                    <th width="10%">热门</th>
                    <th width="250px" class="table-set">操作</th>
                </tr>
                </thead>
                <tbody>
                @if(!empty($rows['data']))
                    @foreach($rows['data'] as $v)
                        <tr id="tr_{{$v['id']}}">
                            <td>{{$v['id']}}</td>
                            <td>
                                <img src="{{$v['avatar'] ? url('/').'/'.$v['avatar'] : '/avatar/default.gif'}}"
                                     width="30px" height="30px">
                                &nbsp; @if($v['is_hot'])<span style="color: red"><b><i>hot</i></b></span>@endif
                            </td>
                            <td>{{$v['name']}}</td>
                            <td>{{$v['job']}}</td>
                            <td>{{$v['pro_title']}}</td>
                            <td>{{$v['origin_company']}}</td>
                            <td class="am-hide-sm-only">
                                @if($v['status'] == 1)
                                    <button class="am-btn am-btn-success am-radius">正常</button>
                                @else
                                    <button class="am-btn am-btn-danger am-radius">禁用</button>
                                @endif
                            </td>
                            <td class="am-hide-sm-only">
                                @if($v['is_hot'] == 1)
                                    <a href="javascript:;" onclick="changeHot({{$v['id']}},0)"
                                       class="am-btn am-btn-default am-btn-xs am-text-secondary am-round"
                                       title="点击改变状态">
                                        <span class="am-icon-check am-text-primary"></span>
                                    </a>
                                @else
                                    <a href="javascript:;" onclick="changeHot({{$v['id']}},1)"
                                       class="am-btn am-btn-default am-btn-xs am-text-secondary am-round"
                                       title="点击改变状态">
                                        <span class="am-icon-close am-text-primary"></span>
                                    </a>
                                @endif
                            </td>
                            <td style="width: 10%;">
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        @if($v['status'] == 1)
                                            <a href="javascript:;" onclick="changeStatus({{$v['id']}},0)"
                                               class="am-btn am-btn-default am-btn-xs am-text-secondary am-round"
                                               title="禁用">
                                                <span class="am-icon-close am-text-primary"></span>
                                            </a>
                                        @else
                                            <a href="javascript:;" onclick="changeStatus({{$v['id']}},1)"
                                               class="am-btn am-btn-default am-btn-xs am-text-secondary am-round"
                                               title="启用">
                                                <span class="am-icon-check am-text-primary"></span>
                                            </a>
                                        @endif
                                        <a href="{{urlAdmin('doctor','getEdit',['id'=>$v['id']],2)}}"
                                           class="am-btn am-btn-default am-btn-xs am-text-secondary am-round">
                                            <span class="am-icon-pencil-square-o"></span>
                                        </a>
                                        <a href="javascript:;" onclick="del({{$v['id']}})"
                                           class="am-btn am-btn-default am-btn-xs am-text-danger am-round">
                                            <span class="am-icon-trash-o"></span>
                                        </a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                @else
                    <tr>
                        <td colspan="7" style="text-align: center"><span>暂无数据~</span></td>

                    </tr>
                @endif
                </tbody>
            </table>
            @if(!empty($rows['pageNoList']))
                <ul class="am-pagination am-fr">
                    <li @if(!$rows['prev_page_url']) class="am-disabled" @endif ><a
                                href="{{$rows['prev_page_url']}}">«</a></li>
                    @foreach($rows['pageNoList'] as $v)
                        <li @if($rows['current_page'] == $v) class="am-active" @endif><a
                                    href="{{urlAdmin('doctor','getIndex',['page'=>$v],2)}}">{{$v}}</a></li>
                    @endforeach
                    <li @if(!$rows['next_page_url']) class="am-disabled" @endif><a
                                href="{{$rows['next_page_url']}}">»</a></li>
                </ul>
            @endif
            <hr/>
        </form>
        @include('admin.footer')
    </div>
@section('script')
    <script>
        function changeStatus(id, status) {
            $.ajax({
                type: "get",
                url: "{{urlAdmin('doctor','getModifyStatus')}}?id=" + id + "&status=" + status,
                dataType: "json",
                success: function (res) {
                    if (res['state'] == 1) {
                        layer.msg(res.msg, {icon: 6}, function () {
                            location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {icon: 5});
                    }
                }
            })
        }
        function del(id) {
            layer.confirm('您确定要删除吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.ajax({
                    type: "get",
                    url: "{{urlAdmin('doctor','getDel')}}?id=" + id,
                    dataType: "json",
                    success: function (res) {
                        if (res['state'] == 1) {
                            layer.msg(res.msg, {icon: 6});
                            $("#tr_" + id).hide();
                        } else {
                            layer.msg(res.msg, {icon: 5});
                        }
                    }
                })

            });
        }

        function changeHot(id, value) {
            $.ajax({
                type: "get",
                url: "{{urlAdmin('doctor','getChangeHot')}}?id=" + id + "&status=" + value,
                dataType: "json",
                success: function (res) {
                    if (res['state'] == 1) {
                        layer.msg(res.msg, {icon: 6}, function () {
                            location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {icon: 5});
                    }
                }
            })
        }
    </script>
@endsection
@endsection